<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  version="1.0" >

<!-- rule for the whole document: root element is page -->

<xsl:template match="base">
 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:layout-master-set>

  <!-- Definition of a single master page. It is simple (no headers etc.) -->
  <fo:simple-page-master 
			 master-name="first" 
			 margin-left="2cm"  margin-right="2cm"
			 margin-bottom="0.5cm" margin-top="0.75cm"
			 page-width="21cm" page-height="29.7cm"
			 >
   <!-- required element body -->
   <fo:region-body />
  </fo:simple-page-master>
 </fo:layout-master-set>
 
 <!-- Definition of a page sequence -->
 <fo:page-sequence master-reference="first">
  <fo:flow flow-name="xsl-region-body" font-size="14pt" line-height="14pt">
    <xsl:apply-templates select="title"/>
  </fo:flow>  
 </fo:page-sequence> 
</fo:root>
</xsl:template>

<!-- A series of XSLT rules that produce fo:blocks to be inserted above -->

 <xsl:template match="base/title">
    <fo:block font-size="36pt" text-align="center" line-height="40pt" space-before="0.5cm" space-after="1.0cm">
    <xsl:apply-templates/></fo:block>
    <fo:block font-size="20pt" text-align="left" line-height="26pt" space-before="0.2cm" space-after="0.2cm">
    <xsl:text>Nos pizzas :</xsl:text></fo:block>
    <xsl:apply-templates select="../pizza"/>
    
    <fo:block font-size="20pt" text-align="left" line-height="26pt" space-before="0.2cm" space-after="0.2cm">
    <xsl:text>Nos boissons :</xsl:text></fo:block>
    <xsl:apply-templates select="../boisson"/>
    
    <fo:block font-size="20pt" text-align="left" line-height="26pt" space-before="0.2cm" space-after="0.2cm">
    <xsl:text>Nos ingredients :</xsl:text></fo:block>
    <xsl:apply-templates select="../ingredientBase"/>
    
    <fo:block font-size="20pt" text-align="left" line-height="26pt" space-before="0.2cm" space-after="0.2cm">
    <xsl:text>Nos menus :</xsl:text></fo:block>
    <xsl:apply-templates select="../menu"/>
  </xsl:template>
  
  <xsl:template match="ingredientBase">
    <fo:block text-align="justify"  space-before="0.5cm">
    <xsl:text> - </xsl:text><xsl:value-of select="@name"/>
    <xsl:text> ( stock = </xsl:text><xsl:value-of select="@stock"/><xsl:text> )</xsl:text>
    </fo:block>
  </xsl:template>

 <xsl:template match="pizza">
    <fo:block text-align="justify"  space-before="0.5cm">
    <xsl:text> - </xsl:text><xsl:value-of select="@name"/>
    <xsl:text>, price : </xsl:text><xsl:value-of select="@price"/>
    <xsl:text>, vegetarian : </xsl:text><xsl:value-of select="@vegetarian"/>
    
    <xsl:text>.  ( </xsl:text>
    <xsl:for-each select="ingredient">
         <xsl:apply-templates select="."/>
    </xsl:for-each>
    <xsl:text>)</xsl:text>
    </fo:block>
  </xsl:template>
  
  <xsl:template match="boisson">
    <fo:block text-align="justify"  space-before="0.5cm">
    <xsl:text> - </xsl:text><xsl:value-of select="@name"/>
    <xsl:text>, price : </xsl:text><xsl:value-of select="@price"/>
    </fo:block>
  </xsl:template>
  
  <xsl:template match="menu">
    <fo:block text-align="justify"  space-before="0.5cm">
    <xsl:text> - </xsl:text><xsl:value-of select="@name"/>
    <xsl:text>, price : </xsl:text><xsl:value-of select="@price"/>
    <xsl:text>, description : </xsl:text><xsl:value-of select="@description"/>
    <xsl:text> ( </xsl:text><xsl:value-of select="@nbPizzas"/>
    <xsl:text> Pizzas, </xsl:text><xsl:value-of select="@nbBoissons"/>
    <xsl:text> Boissons )</xsl:text>
    </fo:block>
  </xsl:template>
  

 <xsl:template match="ingredient">
    <xsl:value-of select="."/><xsl:text> </xsl:text>
  </xsl:template>


</xsl:stylesheet>
